import { rankSongDetail, songOfSongId } from 'api/index'
import { createSong } from "../common/js/song";

export function getRankSongList (id) {
  return rankSongDetail(id).then(res => {
    if(res){
      let list=[]
      res.forEach((item) => {
        if(item.id && item.songId) {
          songOfSongId(item.songId).then(res => {
            let ret = Object.assign({},res,{rankSongId : item.id})
            //console.log(ret)
            list.push(createSong(ret))
            //list.push(ret)
          })
        }
      })
      list.sort((a,b) => {
        return a.rankSongId - b.rankSongId
      })
      //console.log(list)
      return list
    }
  })
}

